# dome_chuck.py

from __future__ import division

from ot_simulator.component import component

class dome_chuck(component.component):
    '''This chuck cuts domes and bowl shapes.

    The `eccentricity` is the distance from the center of the chuck to the
    nosewheel.  A positive eccentricy moves the nosewheel downward (-Y).

    `Oblique` is subtracted from 90 to get the amount to rotate the nosewheel
    on the X axis.  The 90 deg rotation points the nosewheel towards the
    centerline of the chuck.  The `oblique` backs off on that rotation, to
    tilt the nosewheel back toward the tailstock.

    ===============  ==========================
     Input setting   
    ===============  ==========================
    eccentricity     defaults to 0
    oblique          defaults to 0
    nosewheel_index  degrees, defaults to 0
    ===============  ==========================

    ===============  ==========================
    Output setting
    ===============  ==========================
    <none>
    ===============  ==========================
    '''
    input_parameters = ('eccentricity', 'oblique', 'nosewheel_index')

    def get_transform(self, params, transform_in):
        transform_out = transform_in
        eccentricity = self.get_param(params, 'eccentricity', 0.0)
        oblique = self.get_param(params, 'oblique', 0.0)
        nosewheel_index = self.get_param(params, 'nosewheel_index', 0.0)
        if eccentricity:
            transform_out = transform_out.move(y=-eccentricity)
        transform_out = transform_out.rotate_x(-(90.0 - oblique))
        if nosewheel_index:
            transform_out = transform_out.rotate_z(nosewheel_index)
        return transform_out


def test():
    import doctest
    import sys
    sys.exit(doctest.testmod()[0])

if __name__ == "__main__":
    test()
